import { Component, OnInit, ViewEncapsulation } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import config from '../common/utils/baseUrl';
import getData_ajax from '../common/utils/getData_ajax';
import { NzMessageService } from 'ng-zorro-antd';
import { NzModalService } from 'ng-zorro-antd';
import * as $ from 'jquery';
import { ActivatedRoute } from '@angular/router';

@Component({
    selector: 'app-artile-details',
    templateUrl: './artile-details.component.html',
    styleUrls: ['./artile-details.component.scss'],
    encapsulation: ViewEncapsulation.Emulated
})
export class ArtileDetailsComponent implements OnInit {
    // 加载状态
    public isSpinning: any = true;
    // 文章数据
    public ariticeData: any = {};
    // url参数地址
    public queryParams: any = {};

    constructor(private http: HttpClient,
                private message: NzMessageService,
                private modalService: NzModalService,
                private activatedRoute: ActivatedRoute) {
    }

    ngOnInit() {
        this.activatedRoute.queryParams.subscribe(params => {
            this.queryParams = params;
        });
        this.getData();
    }

    /**
     * 初始化数据
     */
    getData() {
        let that = this;
        getData_ajax.getFunc(config.baseUrl + '/articleService/getArticeData', 'post', this.queryParams, function (data) {
                that.ariticeData = data.result[0];
                that.isSpinning = false;
                // console.log(that.ariticeData);
            },
            function (error) {
                console.log(error);
            });
    }
}
